<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'user.label', default: 'user')}"/>
    <title>用户管理</title>
    <style>
    .table>tbody>tr>td{
        vertical-align: middle;
    }
    </style>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span>用户管理</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                用户管理
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">

    <div class="row">
        <g:if test="${flash.message}">
            <div class="message alert alert-info" role="status">${flash.message}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
            </div>
        </g:if>
        <g:form method="POST" action="searchUser">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit"><i class="fa fa-search"></i>查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i>重置</button>
                    </div>
                    查询
                </div>
                <div class="panel-body">
                    <div class="col-sm-3">
                        <input type="text" class="form-control" placeholder="姓名" name="fullName" id="fullName"
                               value="${user?.fullName}">
                    </div>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" placeholder="用户名" name="username" id="username"
                               value="${user?.username}">
                    </div>
                    <div class="col-sm-3">
                        <g:select class="form-control m-b" name="enabled" id="enabled"
                                  from="${[[name:'正常',value:true],[name:'禁用',value:false]]}" optionValue="name" optionKey="value"
                                  value="${params?.enabled}"
                                  noSelection="${['': '用户状态']}"/>
                    </div>
                    <div class="col-sm-4"></div>
                </div>
            </div>
        </g:form>
    </div>

    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <g:link action="create" class="btn btn-info btn-xs"><i class="fa fa-plus"></i>新建</g:link>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部用户
            </div>
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center">
                        <thead>
                        <tr>
                            <g:sortableColumn property="fullName"
                                              title="${message(code: 'user.fullName.label', default: '姓名')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                            <g:sortableColumn property="username"
                                              title="${message(code: 'user.username.label', default: '用户名')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                            <g:sortableColumn property="createdDate"
                                              title="${message(code: 'user.role.label', default: '权限')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                            <g:sortableColumn property="cellphone"
                                              title="${message(code: 'user.cellphone.label', default: '联系电话')}" params= "${params}" action="searchUser"  class="col-md-1 text-center"/>
                            <g:sortableColumn property="account"
                                              title="${message(code: 'user.cellphone.label', default: '所属机构')}" params= "${params}" action="searchUser"  class="col-md-1 text-center"/>
                            <g:sortableColumn property="enabled"
                                              title="${message(code: 'user.enabled.label', default: '状态')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                            <g:sortableColumn property="enabled"
                                              title="${message(code: 'user.expiredDate.label', default: '账号有效期')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                            <g:sortableColumn property="createdDate"
                                              title="${message(code: 'user.createdDate.label', default: '创建日期')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                            <g:sortableColumn property="skin"
                                              title="${message(code: 'user.createdDate.label', default: '主题色')}" params= "${params}" action="searchUser" class="col-md-1 text-center"/>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${userList}">
                            <tr>
                                <td class="text-center"><g:link action="show" id="${it?.id}" class="firstTd">${it?.fullName}</g:link></td>
                                <td class="text-center">${it?.username}</td>
                                <td class="text-center">${it?.roleName}</td>
                                <td class="text-center">${it?.cellphone}</td>
                                <td class="text-center">${it?.accountname}</td>
                                <td class="text-center">${it?.enabled ? '正常': '禁用'}</td>
                                <td class="text-center"><g:formatDate date="${it?.expiredDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate></td>
                                <td class="text-center"><g:formatDate date="${it?.createdDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate></td>
                                <td class="text-center">${it?.skin?'深色':'浅色'}</td>
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate total="${userCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>
<g:javascript>
    $(function () {
        //重置按钮
        $("#resetBtn").click(function () {
            $("#fullName").val("");
            $("#username").val("");
            $("#s2id_enabled span:first").html("用户状态");
            $("#enabled").val("");

        })
        $("#create").click(function (){
            location.href="create"
        });
    });

</g:javascript>
</body>
</html>
